home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / musictex / older-versions / musictex.500 / MUSICEXT.TEX < prev    next >
Text File  |  1993-12-31  |  10KB  |  226 lines

  1.  
  2.  
  3. \edef\catcodeat{\the\catcode`\@}\catcode`\@=11
  4. \edef\catcode@gt{\the\catcode`\>}\catcode`\>=12
  5. \edef\catcode@lt{\the\catcode`\<}\catcode`\<=12
  6.  
  7. % \dyn {pitch}{text} inserts a dynamic
  8. \def\dyn#1#2{\zcharnote{#1}{{\ppff #2}}}
  9.  
  10. % \nobarnumbers prevents bar numbering
  11. \def\nobarnumbers{\def\wbarno{\relax}}
  12.  
  13. % \barnumbers restores bar numbering
  14. \def\barnumbers{\def\wbarno{\w@barno}}
  15.  
  16. % \tab is defined as a tab character, so that I can still use tabs.
  17. \catcode`\@=4
  18. \let\tab=@
  19. \catcode`\@=11
  20.  
  21. % The next few sections define some extra macros to produce notes.
  22.  
  23. % shifted dotted whole notes
  24. \def\rwp#1{\kern \wd@skip\zwp{#1}\kern -\wd@skip}
  25. \def\lwp#1{\kern -\wd@skip\zwp{#1}\kern \wd@skip}
  26.  
  27. % Half-shifted notes. I sometimes use these for close intervals: for instance
  28. % \zlqu g\zrql f
  29.  
  30. \def\zrwh{\zrw}
  31. \def\zlwh{\zlw}
  32. \def\zrw#1{\kern .52\wd@skip\zw{#1}\kern -.52\wd@skip}
  33. \def\zlw#1{\kern -.52\wd@skip\zw{#1}\kern .52\wd@skip}
  34. \def\zrhu#1{\kern .45\hn@width\zhu{#1}\kern -.45\hn@width}
  35. \def\zlhu#1{\kern -.45\hn@width\zhu{#1}\kern .45\hn@width}
  36. \def\zrhl#1{\kern .45\hn@width\zhl{#1}\kern -.45\hn@width}
  37. \def\zlhl#1{\kern -.45\hn@width\zhl{#1}\kern .45\hn@width}
  38. \def\zrhup#1{\kern .45\hn@width\zhup{#1}\kern -.45\hn@width}
  39. \def\zlhup#1{\kern -.45\hn@width\zhup{#1}\kern .45\hn@width}
  40. \def\zrhlp#1{\kern .45\hn@width\zhlp{#1}\kern -.45\hn@width}
  41. \def\zlhlp#1{\kern -.45\hn@width\zhlp{#1}\kern .45\hn@width}
  42. \def\zrqu#1{\kern .45\qd@skip\zqu{#1}\kern -.45\qd@skip}
  43. \def\zlqu#1{\kern -.45\qd@skip\zqu{#1}\kern .45\qd@skip}
  44. \def\zrql#1{\kern .45\qd@skip\zql{#1}\kern -.45\qd@skip}
  45. \def\zlql#1{\kern -.45\qd@skip\zql{#1}\kern .45\qd@skip}
  46. \def\zrqup#1{\kern .45\qd@skip\zqup{#1}\kern -.45\qd@skip}
  47. \def\zlqup#1{\kern -.45\qd@skip\zqup{#1}\kern .45\qd@skip}
  48. \def\zrqlp#1{\kern .45\qd@skip\zqlp{#1}\kern -.45\qd@skip}
  49. \def\zlqlp#1{\kern -.45\qd@skip\zqlp{#1}\kern .45\qd@skip}
  50. \def\zrcu#1{\kern .45\qd@skip\zcu{#1}\kern -.45\qd@skip}
  51. \def\zlcu#1{\kern -.45\qd@skip\zcu{#1}\kern .45\qd@skip}
  52. \def\zrcl#1{\kern .45\qd@skip\zcl{#1}\kern -.45\qd@skip}
  53. \def\zlcl#1{\kern -.45\qd@skip\zcl{#1}\kern .45\qd@skip}
  54. %
  55. % half left shifted accidentals - for putting before half shifted notes
  56. %
  57. \def\hlfl#1{\getn@i{#1}\global\n@raise=\fl@raise
  58.   \pl@llap{\f@lat\kern 0.45\qd@skip}%
  59. }%
  60. \def\hldfl#1{\getn@i{#1}\global\n@raise=\fl@raise
  61.   \pl@llap{\df@lat\hskip 0.45\qd@skip}%
  62. }%
  63. \def\hlsh#1{\getn@i{#1}\global\n@raise=\sh@raise
  64.   \pl@llap{\s@harp\hskip 0.45\qd@skip}%
  65. }%
  66. \def\hldsh#1{\getn@i{#1}\global\n@raise=\z@
  67.   \pl@llap{\ds@harp\hskip 0.45\qd@skip}}%
  68. \def\hlna#1{\getn@i{#1}\global\n@raise=\na@raise
  69.   \pl@llap{\n@at\hskip 0.45\qd@skip}}%
  70.  
  71. %
  72. % The following macros can be used to surround a note by parentheses. They
  73. % are also used as ornaments by J.P. Rameau.
  74. % \lpar p  produces a left parenthesis, or "port de voix" at pitch p
  75. % \rpar p  produces a right parenthesis, or "pinc\'e"
  76.  
  77. \def\lpar#1{\zcharnote{#1}{\raise -2.5pt\hbox{\tentt\kern -0.76\wd@skip (}}}
  78. \def\rpar#1{\zcharnote{#1}{\raise -2.5pt\hbox{\tentt\kern 0.76\wd@skip )}}}
  79.  
  80.  
  81. \newdimen\tmp@dimen
  82. \def\bracketshrink{0.17\Interligne}
  83.  
  84. % \bracket pn draws a square bracket ( [ ) to bracket an interval of an n-th
  85. % whose lowest note is p.
  86.  
  87. \def\bracket#1#2{\tmp@dimen #2\Interligne\advance\tmp@dimen by\Interligne
  88.    \divide\tmp@dimen by2\relax
  89.    \advance\tmp@dimen by-\bracketshrink\advance\tmp@dimen by-\bracketshrink
  90.    \advance\tmp@dimen by-\lthick
  91.    \zcharnote#1{\kern-.75\Interligne\raise-.5\Interligne
  92.    \hbox{\raise\bracketshrink\hbox{\rlap{\vrule height\tmp@dimen}\relax
  93.    \rlap{\vbox{\hrule width .5\Interligne}}\relax
  94.    \raise\tmp@dimen\vbox{\hrule width .5\Interligne}}}}}
  95.  
  96. \newdimen\tmp@dimenc
  97. \newdimen\z@iii\newdimen\z@iv\newdimen\z@v
  98.  
  99. % \oblique {l}{s}{h} draws an oblique line of length l, slope s percent, and
  100. % height h. This will cause an unrecorded space so it should be used within
  101. % \rlap. Note that this macro is a hack and probably gobbles up resources!
  102. % This macro is used by some of the others which follow.
  103.  
  104. \def\oblique#1#2#3{\relax % length slope height
  105. \ifnum #2=0\relax\raise #3\vbox{\hrule width #1 height\lthick depth\z@}\relax
  106. \else\q@antum=25\lthick\divide\q@antum by #2\relax
  107. \ifdim\q@antum<0pt\relax\multiply\q@antum by -1\fi
  108. \global\z@iv=0pt\relax
  109. \loop\ifdim\z@iv<#1\relax
  110.  {\z@v=#1\relax\advance\z@v by -\z@iv\relax\advance\z@v by -\q@antum\relax
  111.  \tmp@dimenc\z@iv\multiply\tmp@dimenc by#2\relax
  112.  \z@iii=#3\relax\advance\z@iii by .01\tmp@dimenc\relax\advance\z@iii by
  113.  -0.5\internote
  114.  \ifnum #2<0\relax\advance\z@iii by \lthick\relax\fi
  115.  \tmp@dimenc\z@v\multiply\tmp@dimenc by#2\relax
  116.  \ifdim\z@v<0pt\relax\advance\z@iii by .01\tmp@dimenc\relax\hskip\z@v\fi
  117.  \advance\z@iii by 0.6\internote\relax
  118.  \raise\z@iii\hbox to \q@antum{\vrule width\q@antum height .5\lthick depth
  119.  .5\lthick}\relax
  120.  \global\advance\z@iv by \q@antum\relax
  121. }\repeat
  122. \fi
  123. }
  124.  
  125. \newdimen\tmp@dimenb\newcount\tmp@ct
  126. \def\crescwidth{1.8\Interligne}
  127.  
  128. % These macros produce variable size crescendo and diminuendo marks.
  129. % \varcresc{p}{l} produces a crescendo at pitch p, and of length l, causing
  130. % no space.
  131. \def\varcresc#1#2{\relax% height (note), length (dimen)
  132.    \tmp@dimenb \crescwidth\tmp@dimen #2\multiply
  133.    \tmp@dimenb by50\divide\tmp@dimenb by\tmp@dimen \tmp@ct\tmp@dimenb
  134.    \ifnum 0=\tmp@ct\relax
  135.    \tmp@ct 1\fi
  136.    \getn@i{#1}\tmp@dimen\n@i\internote
  137.    \rlap{\oblique{#2}{\tmp@ct}{\tmp@dimen}}\relax
  138.    \advance\tmp@dimen by-\lthick
  139.    \rlap{\oblique{#2}{-\tmp@ct}{\tmp@dimen}}}
  140.  
  141. % \vardim{p}{l}  draws a diminuendo at pitch p, and of length l, causing
  142. % no space.
  143. \def\vardim#1#2{\tmp@dimenb 1.6\Interligne\tmp@dimen #2\multiply
  144.    \tmp@dimenb by50\divide\tmp@dimenb by\tmp@dimen \tmp@ct\tmp@dimenb
  145.    \ifnum 0=\tmp@ct\relax
  146.    \tmp@ct 1\fi
  147.    \getn@i{#1}\tmp@dimen\n@i\internote
  148.    \tmp@dimenb\crescwidth\divide\tmp@dimenb by2\relax
  149.    \advance\tmp@dimen by\tmp@dimenb
  150.    \rlap{\oblique{#2}{-\tmp@ct}{\tmp@dimen}}\relax
  151.    \advance\tmp@dimen by \lthick
  152.    \tmp@dimenb #2\multiply\tmp@dimenb by\tmp@ct\advance\tmp@dimen
  153.  by-.02\tmp@dimenb
  154.    \rlap{\oblique{#2}{\tmp@ct}{\tmp@dimen}}}
  155.  
  156. % \overbracket{p}{l}{s}   draws a bracket over the music starting at the
  157. % current position at pitch p, width l and slope s percent, causing no space.
  158. \def\overbracket#1#2#3{\relax % height (note), length (dimen) slope (%)
  159.    \tmp@dimenb #2\multiply\tmp@dimenb by#3\divide\tmp@dimenb by100\relax
  160.    \getn@i{#1}\advance\tmp@dimenb by\n@i\internote\rlap{\relax
  161.    \raise\n@i\internote\rlap{\vrule width\lthick height \lthick
  162.    depth .8\Interligne}\oblique{#2}{#3}{\n@i\internote}\relax
  163.    \advance\tmp@dimenb by.5\lthick\relax
  164.    \raise\tmp@dimenb\hbox{\vrule width\lthick height \lthick
  165.  depth.8\Interligne}}}
  166.  
  167. % \ovbkt{p}{n}{s} is the same as \overbracket, except that it draws the
  168. % bracket to cover n notes (note however that glue inserted by \temps
  169. % commands will expand the space between the notes but will not affect the
  170. % bracket).
  171. % I use this macro to indicate triplets, for instance.
  172.  
  173. \def\ovbkt#1#2#3{\relax % height (note), length (number of notes) slope (%)
  174.    \tmp@dimen #2\noteskip\advance\tmp@dimen by\wd@skip\advance\tmp@dimen
  175.    by -\noteskip\advance\tmp@dimen by\lthick \overbracket{#1}{\tmp@dimen}{#3}}
  176.  
  177. % \underbracket and \unbkt are similar to the above, but produce
  178. % brackets under the music.
  179. \def\underbracket#1#2#3{\relax % height (note), length (dimen) slope (%)
  180.    \tmp@dimenb #2\multiply\tmp@dimenb by#3\divide\tmp@dimenb by100\relax
  181.    \getn@i{#1}\advance\tmp@dimenb by\n@i\internote\rlap{\relax
  182.    \raise\n@i\internote\rlap{\vrule width\lthick depth -\lthick
  183.    height \Interligne}\oblique{#2}{#3}{\n@i\internote}\relax
  184.    \advance\tmp@dimenb by.5\lthick\relax
  185.    \raise\tmp@dimenb\hbox{\vrule width\lthick depth -\lthick
  186.  height\Interligne}}}
  187. \def\unbkt#1#2#3{\relax % height (note), length (number of notes) slope (%)
  188.    \tmp@dimen #2\noteskip\advance\tmp@dimen by\wd@skip\advance\tmp@dimen
  189.    by -\noteskip\advance\tmp@dimen by\lthick
  190.    \kern-2\lthick\underbracket{#1}{\tmp@dimen}{#3}\kern2\lthick}
  191.  
  192. % Here are several macros to make use of the alternative note graphics found
  193. % in the font files. I copied the idea from the usual note macros in
  194. % MusicTeX.
  195.  
  196.  
  197. % \ttrill p    makes a terminated trill ...
  198. \def\ttrill#1{\zcharnote{#1}{\o@skp\musicnorfont\char"58\dimen@4.6pt%
  199.    \advance\dimen@-1.5\internote\tenrm\lower\dimen@\hbox{'}}}
  200.  
  201. % J.P. Rameau indicated "arpegements" by drawing oblique strokes through the
  202. % note stems.
  203. % \downarpeg p  is written just before the note at pitch p with its stem
  204. %               pointing up in order to indicate a descending arpeggio
  205. % \uparpeg p    is written just before the note at pitch p with its stem
  206. %               pointing down in order to indicate an ascending arpeggio
  207.  
  208. \font\linew=linew10 %would be nice to have slightly shorter lines...
  209. \def\downarpeg#1{\getn@i{#1}\advance\n@i by3\raise\n@i\internote
  210.  \rlap{\linew\char"61}}
  211. \def\uparpeg#1{\getn@i{#1}\advance\n@i by-3\raise\n@i\internote
  212.  \rlap{\linew\char"21}}
  213.  
  214. % \qqs is a demi-semiquaver rest
  215. \def\qqs{\charnote0{{\musicnorfont\char"41}}}
  216.  
  217. % These macros change context while forbidding line breaks
  218. \def\xchangecontext{{\def\updatecontext{\x@updatecon}\changecontext}}
  219. \def\xChangecontext{{\def\updatecontext{\x@updatecon}\Changecontext}}
  220.  
  221.  
  222. \catcode`\>=\catcode@gt
  223. \catcode`\<=\catcode@lt
  224. \catcode`\@=\catcodeat
  225.  
  226.